<template>
    <el-dialog v-model:dialogVisible="dialogVisible" title="Tips" width="30%" :before-close="handleClose">
        <span>This is a message</span>
        <template #footer>
            <span class="dialog-footer">
                <el-button @click="dialogVisible">Cancel</el-button>
                <el-button type="primary" @click="dialogVisible">Confirm
                </el-button>
            </span>
        </template>
    </el-dialog>
</template>

<script lang="ts" setup>
import { ref, defineProps } from 'vue'
import { ElMessageBox } from 'element-plus'

const dialogVisible = ref(true)
// const props = defineProps({
//   dialogVisible: {
//     types: Boolean,
//     default: true
//   }
// })

const handleClose = (done: () => void) => {
  ElMessageBox.confirm('Are you sure to close this dialog?')
    .then(() => {
      done()
    })
    .catch(() => {
      // catch error
    })
}
</script>
<style scoped>
.dialog-footer button:first-child {
    margin-right: 10px;
}
</style>
